import * as React from 'react'; import { TextAreaField, Flex, FlexContainerStyleProps, BaseTextAreaFieldProps, } from '@aws-amplify/ui-react'; import { Demo } from '@/components/Demo'; import { useTextAreaFieldProps } from './useTextAreaFieldProps'; import { GetFieldControls } from '../shared/GetFieldControls'; import { useFlexContainerStyleProps } from '../shared/useFlexContainerStyleProps'; import { TextAreaFieldPropControls } from './TextAreaFieldPropControls'; export const TextAreaFieldDemo = () => { const flexStyleProps = useFlexContainerStyleProps({ alignItems: '', alignContent: '', direction: 'column', gap: '', justifyContent: '', wrap: 'nowrap', }); const textFieldProps = useTextAreaFieldProps({ autoComplete: 'off', defaultValue: null, descriptiveText: 'Enter a valid last name', errorMessage: '', hasError: false, isDisabled: false, isReadOnly: false, isRequired: false, label: 'Last name', labelHidden: false, name: 'last_name', placeholder: 'Baggins', rows: 3, maxLength: null, size: 'small', value: null, variation: null, }); const FlexPropControls = GetFieldControls({ typeName: 'Flex', fields: flexStyleProps, }); const [ [alignItems], [alignContent], [direction], [gap], [justifyContent], [wrap], ] = flexStyleProps; const { autoComplete, defaultValue, hasError, label, descriptiveText, errorMessage, isDisabled, isReadOnly, isRequired, labelHidden, placeholder, size, rows, maxLength, value, name, variation, } = textFieldProps; const code = ` console.info(e.currentTarget.value)} onInput={(e) => console.info('input fired:', e.currentTarget.value)} onCopy={(e) => console.info('onCopy fired:', e.currentTarget.value)} onCut={(e) => console.info('onCut fired:', e.currentTarget.value)} onPaste={(e) => console.info('onPaste fired:', e.currentTarget.value)} onSelect={(e) => console.info( 'onSelect fired:', e.currentTarget.value.substring( e.currentTarget.selectionStart, e.currentTarget.selectionEnd ) ) } />`; return ( {FlexPropControls} } > console.info(e.currentTarget.value)} onInput={(e) => console.info('input fired:', e.currentTarget.value)} onCopy={(e) => console.info('onCopy fired:', e.currentTarget.value)} onCut={(e) => console.info('onCut fired:', e.currentTarget.value)} onPaste={(e) => console.info('onPaste fired:', e.currentTarget.value)} onSelect={(e) => console.info( 'onSelect fired:', e.currentTarget.value.substring( e.currentTarget.selectionStart, e.currentTarget.selectionEnd ) ) } /> ); };